//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
    imgs:{},
    images: []
  },
  imageLoad: function(e) {
     var $width=e.detail.width,    //获取图片真实宽度
         $height=e.detail.height;
      var image=this.data.images;      //将图片的datadata-index作为image对象的key,然后存储图片的宽高值
      
      if(e.target.dataset.type == 'full') {
        var screenWidth_rpx = wx.getSystemInfoSync().screenWidth;
        var ratio=$width/$height;    //图片的真实宽高比例
        var viewWidth=screenWidth_rpx,           //设置图片显示宽度，左右留有16rpx边距
            viewHeight=screenWidth_rpx/ratio;    //计算的高度值
        image[e.target.dataset.key]={
         width:viewWidth,
         height:viewHeight
        }
        //轮播图片最小高度
        if(this.data.swiperHeight == 0 || this.data.swiperHeight > viewHeight) {
          this.setData({
            swiperHeight: viewHeight
          });
        }
      } else {
        image[e.target.dataset.key]={
         width:$width,
         height:$height
        }
      }
      
      this.setData({
           images:image
      })
  },
  onLoad: function (options) {
    this.setData({
      imgs: options
    });
  }
})
